#!/bin/bash -e

function info() {
echo Usage: `basename $0` [-e err_rate -m min_len] reads1.fq[.gz] reads2.fq[.gz]
exit 2
}


while getopts  ":e:m:p:" opts
do
        case  $opts  in
		e) err_rate=$OPTARG;;
        m) min_len=$OPTARG;;
		p) out_prefix=$OPTARG;;
		*) info;;
        esac
done
shift $(($OPTIND - 1))

if [ -z "$2" ]; then info; fi
if [ -z "$min_len" ]; then min_len=20; fi
if [ -z "$err_rate" ]; then err_rate=0.16; fi

. $var

# export cutadapt=$tools_path/py_module/bin/cutadapt



cutadp_170214.sh -p${out_prefix}_g $@

cutadp_amplicon.sh -p${out_prefix}_a ${out_prefix}_g.1.cut.fastq ${out_prefix}_g.2.cut.fastq

cutadp_malbac_170214.sh -p${out_prefix} ${out_prefix}_a.1.cut.fastq ${out_prefix}_a.2.cut.fastq

# cutadp_cut.sh -p$out_prefix ${out_prefix}_m.1.cut.fastq ${out_prefix}_m.2.cut.fastq

rm ${out_prefix}_g.*.cut.fastq ${out_prefix}_a.*.cut.fastq 

. $cmd_done

